<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
        <meta charset="utf-8">
        <title><?php echo ($seo_title); ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <script src="/Static/mobile/js/jquery.js"></script>
        <script src="/Static/mobile/js/layer.mobile-v1.6/layer.m.js"></script>
        <script src="/Static/mobile/js/common.js?i=1"></script>
        <link rel="stylesheet" type="text/css" href="/Static/mobile/iconfont/iconfont.css">
        <link rel="stylesheet" href="//at.alicdn.com/t/font_813618_4lm1s8y9h0t.css">
        <script>
        var _hmt = _hmt || [];
        (function() {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?a524f349a84f50ed8afa8dcd907a59e9";
                var s = document.getElementsByTagName("script")[0]; 
                s.parentNode.insertBefore(hm, s);
        })();
        </script>
        <!-- 微信分享 -->
        
	</head>
<body>


<link rel="stylesheet" href="/Static/mobile/vant/index.css">
<script src="/Static/mobile/vant/vue.min.js"></script>
<script src="/Static/mobile/vant/vant.min.js"></script>
<link rel="stylesheet" href="/Static/mobile/applogin/css/mylogin.css">
<div  style="display:none;" id="app" class='conatainer'>
    <div class="btn-group">
        <div v-if="haswx" @click="login" class='wx-login-div'>
            <img class='icon_pic wx-icon' src="/Static/mobile/applogin/images/wx.png" alt="">
            <span>微信登陆</span>
        </div>

        <div @click="location.href='/mobile/login/mobilelogin'" class='mobile-login-div'>
            <img class='icon_pic' src="/Static/mobile/applogin/images/mobile_white.png" alt="">
            <span>手机登陆</span>
        </div>
    </div>
</div>

<script>
    function vueInit () {
        var app = new Vue({
            el: '#app',
            data: {
                mobileLoginShow: false,
                loginInfo:{},
                register:{},
                haswx: false,
                activeTab:0,
                sendNum:0,
                sendText:'发送验证码',
                version:'',
                os:''
            },
            watch: {
                sendNum: function (val,oldval) {
                    if(val!=0) {
                        this.sendText = '已发送';
                    }else{
                        this.sendText = '发送验证码';
                        clearInterval(window.sendTask);
                    }
                }
            },
            created:function () {
                var self = this;
            },
            mounted: function () {
                this.version = plus.runtime.version;
                this.os = plus.os.name;
                /* var quit = '<?=get("quit")?>';
                plus.storage.removeItem('token');
                if(quit) {
                    window.location.href = '/mobile/index';
                    return;
                } */
                $('#app').show();
                
                var self = this;
                if(plus.runtime.isApplicationExist({pname:'com.tencent.mm',action:'weixin://'})){
                    self.haswx = true;
                    if(self.haswx) {
                        var token = plus.storage.getItem('token');
                        if(token) {
                            //window.location.replace('/mobile/index?token='+token);
                        }
                    }
                }
                
            },
            methods: {
                login: function () {
                    var self = this
                    if(!window.plus) {
                        return false
                    }
                    //return false; 
                    plus.oauth.getServices( function (auths) {
                        var wxauth;
                        for(var i=0;i<auths.length;i++) {
                            if(auths[i].id=='weixin') {
                                wxauth = auths[i];
                                break;
                            }
                        }


                        wxauth.authorize(function(e){
                            //alert("授权ok："+e.code);
                            $.ajax({
                                type: 'post',
                                data: {
                                    code:e.code
                                },
                                url: '/mobile/login/app'
                            }).then(function(res) {
                                if(res.ret==0) {
                                    plus.storage.setItem('token', getCookie('token'));
                                    window.location.replace('/mobile/index');
                                }else{
                                    showerror(res.msg);
                                }
                            })
                        }, function(e){
                            alert("授权失败："+JSON.stringify(e));
                        }, {scope:'snsapi_userinfo',state:'authorizetest',appid:'wxb95a3deeed5f0cb0'});
                       
                    })
                }
            }
        });
    }
    document.addEventListener("plusready",function(){
        vueInit();
    },false);
    
    
</script>
<style>
    .van-cell__title {
        max-width: 90px;
    }

    .van-cell__value {
        text-align: left;
    }
</style>
<!-- 如果是微信客户端 -->
<input id="networkType" value="" type="hidden">
<?php if($is_wechat){ ?>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script type="text/javascript">
		wx.config({
		
		<?php if($hlopenid =="oaGjOtyJCTObWB2BZbkLfxyVHTMA"){?>
		 debug:true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，
		
		<?php } ?>
		
		  //若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
		  appId:'<?php echo ($jssign['appid']); ?>', // 必填，公众号的唯一标识
		  timestamp:'<?php echo ($jssign['timestamp']); ?>', // 必填，生成签名的时间戳
		  nonceStr:'<?php echo ($jssign['noncestr']); ?>', // 必填，生成签名的随机串
		  signature:'<?php echo ($jssign['signature']); ?>',// 必填，签名，见附录1
	      jsApiList: [
	                  'checkJsApi',
	                  'onMenuShareTimeline',
	                  'onMenuShareAppMessage',
	                  'onMenuShareQQ',
	                  'onMenuShareWeibo',
	                  'onMenuShareQZone',
	                  'hideMenuItems',
	                  'showMenuItems',
	                  'hideAllNonBaseMenuItem',
	                  'showAllNonBaseMenuItem',
	                  'translateVoice',
	                  'startRecord',
	                  'stopRecord',
	                  'onVoiceRecordEnd',
	                  'playVoice',
	                  'onVoicePlayEnd',
	                  'pauseVoice',
	                  'stopVoice',
	                  'uploadVoice',
	                  'downloadVoice',
	                  'chooseImage',
	                  'previewImage',
	                  'uploadImage',
	                  'downloadImage',
	                  'getNetworkType',
	                  'openLocation',
	                  'getLocation',
	                  'hideOptionMenu',
	                  'showOptionMenu',
	                  'closeWindow',
	                  'scanQRCode',
	                  'chooseWXPay',
	                  'openProductSpecificView',
	                  'addCard',
	                  'chooseCard',
	                  'openCard'
	                ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
		});
		
		wx.ready(function(){
			//分享到朋友圈
		  wx.onMenuShareTimeline({
		    title:'<?php echo $share_title ? $share_title : C("SHARE_DEFAULT_TITLE");?>', // 分享标题
		    link:'<?php echo $share_url ? $share_url : C("SHARE_DEFAULT_URL");?>', // 分享链接
		    imgUrl:'<?php echo $share_img ? $share_img : C("SHARE_DEFAULT_IMG");?>', // 分享图标
		    success: function(){
		    	
		    },
		    cancel: function(){
		    }
		  });
		  //分享给好友
		  wx.onMenuShareAppMessage({
		    title:'<?php echo $share_title ? $share_title : C("SHARE_DEFAULT_TITLE");?>', // 分享标题
		    desc:'<?php echo $share_description ? $share_description : C("SHARE_DEFAULT_DESC");?>', // 分享描述
		    link:'<?php echo $share_url ? $share_url : C("SHARE_DEFAULT_URL");?>', // 分享链接
		    imgUrl:'<?php echo $share_img ? $share_img : C("SHARE_DEFAULT_IMG");?>', // 分享图标
		    type: '',
		    dataUrl: '',
		    success: function () { 
		    },
		    cancel: function () { 
		
		    }
		  });  
		  
		  wx.getNetworkType({
			    success: function (res) {
			        var networkType = res.networkType; // 返回网络类型2g，3g，4g，wifi
			        $("#networkType").val(networkType);
			    }
			});
		  
		  //复制链接menuItem:copyUrl
		  wx.hideMenuItems({
			 menuList: ["menuItem:originPage",
			            "menuItem:share:facebook",
			            "menuItem:share:qq",
			            "menuItem:share:weiboApp",
			            "menuItem:share:QZone",
			            "menuItem:readMode",
			         //   "menuItem:openWithQQBrowser",
			         //   "menuItem:openWithSafari",
			            "menuItem:share:email",
			            "menuItem:share:brand",
			            "menuItem:copyUrl",//复制链接
			            "menuItem:share:timeline",//朋友圈
			            "menuItem:share:appMessage",//朋友
			            ], // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
		      success: function (res) {
		         // alert('已隐藏“阅读模式”，“分享到朋友圈”，“复制链接”等按钮');
		        },
		        fail: function (res) {
		          //alert(JSON.stringify(res));
		        }
		  });
		  
		  //wx.hideOptionMenu();//批量隐藏保护类 传播类按钮
		 
		});

		//浏览图片
		function previewImage(now_pic,pics){
			wx.previewImage({
			   current: now_pic, // 当前显示图片的http链接
			   urls: pics // 需要预览的图片http链接列表
			});
		}
		
		//浏览图片
		$('.previewImageList').on('click', function(){
			var now_pic = $(this).attr("src");
			var pics = new Array();
			
			$('.previewImage').each(function(index) {
				pics[index] = $(this).attr("src");
			 });
			
			previewImage(now_pic,pics);
			
		});

		</script>

<?php } ?>
<script>

var plusobj = {
    createDownload: function (url,callbackFunction) {
        let dtask = plus.downloader.createDownload(url);
        dtask.addEventListener( "statechanged", callbackFunction, false );
        dtask.start(); 
    },
    delFile: function (relativePath) {
        plus.io.resolveLocalFileSystemURL(relativePath, function(entry) {
            entry.remove(function(entry) {
                console.log("文件删除成功==" + relativePath);
            }, function(e) {
                console.log("文件删除失败=" + relativePath);
            });
        });
    },
    shareWeixinPic: function  (files,scene) {
        var self = this;
        plus.share.getServices( function(s){
            var shares = s;
            shares.forEach((item)=>{
              if(item.id='weixin') {
                item.send( {pictures:files,extra:{scene:scene?scene:"WXSceneSession"}}, function(){
                  
                }, function(e){
                  self.delFile(file)
                });
              }
            })
          }, function(e){
            alert( "获取分享服务列表失败："+e.message );
          } );
    },
	shareMsg: function  (msg) {
        var self = this;
        plus.share.getServices( function(s){
            var shares = s;
            shares.forEach((item)=>{
              if(item.id='weixin') {
                item.send(msg, function(){
                }, function(e){
                });
              }
            })
          }, function(e){
          } );
    }
}

function myshare () {
	plus.nativeUI.actionSheet({
		title: '分享到',
		cancel: "取消",
		buttons: [{
			title: "微信消息"
		}, {
			title: "微信朋友圈"
		}]
	}, function(e) {
		var index = e.index;
		if(index<0) {
			return false;
		}
		switch(index) {
			case 1: //分享到微信好友
				plusobj.shareMsg({
					title:'<?php echo $share_title ? $share_title : C("SHARE_DEFAULT_TITLE");?>', // 分享标题
					content:'<?php echo $share_description ? $share_description : C("SHARE_DEFAULT_DESC");?>', // 分享描述
					href: '<?php echo $share_url ? $share_url : C("SHARE_DEFAULT_URL");?>',//分享出去后，点击跳转地址
					thumbs: ['<?php echo $share_img ? $share_img : C("SHARE_DEFAULT_IMG");?>'], //分享缩略图
					extra:{scene:"WXSceneSession"}
				});
				break;
			case 2: //分享到微信朋友圈
				plusobj.shareMsg({
					title:'<?php echo $share_title ? $share_title : C("SHARE_DEFAULT_TITLE");?>', // 分享标题
					content:'<?php echo $share_description ? $share_description : C("SHARE_DEFAULT_DESC");?>', // 分享描述
					href: '<?php echo $share_url ? $share_url : C("SHARE_DEFAULT_URL");?>',//分享出去后，点击跳转地址
					thumbs: ['<?php echo $share_img ? $share_img : C("SHARE_DEFAULT_IMG");?>'], //分享缩略图
					extra:{scene:"WXSceneTimeline"}
				});
				break;
		}
	})
}

document.addEventListener("plusready",function(){
	var token = plus.storage.getItem('token');
	if(token) {
		
		$.get('/mobile/login/tokenLogin?token='+token).then(function(res){
			if(res.ret==1) {
				//清除storage
				plus.storage.removeItem('token');
			}else{
				//alert('登录成功');
			}
		})
	}
	//plus.webview.currentWebview().setStyle({titleNView: {buttons: []}});
	if(plus.os.name=='Android') {
		/* if(plus.runtime.version=='1.0') {
			var url="http://ui.vip36.cn/android2.apk"; 
			var dtask = plus.downloader.createDownload( url, {}, function ( d, status ) {
				if ( status == 200 ) { 
					var path = d.filename;
					plus.runtime.install(path);
				} else {
					alert( "Download failed: " + status ); 
				}  
			});
			dtask.start(); 
		} */
	}
},false);

</script>
<script type='text/javascript'>
    (function(m, ei, q, i, a, j, s) {
        m[i] = m[i] || function() {
            (m[i].a = m[i].a || []).push(arguments)
        };
        j = ei.createElement(q),
            s = ei.getElementsByTagName(q)[0];
        j.async = true;
        j.charset = 'UTF-8';
        j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
        s.parentNode.insertBefore(j, s);
    })(window, document, 'script', '_MEIQIA');
    _MEIQIA('entId', 132278);
</script>
<script>
        var winHeight = $(window).height();  //获取当前页面高度
        $(window).resize(function () {
            var thisHeight = $(this).height();
            if ( winHeight - thisHeight > 140 ) {
                //键盘弹出
                $('.bottom-fixed').hide();
            } else {
                //键盘收起
                $('.bottom-fixed').show();
            }
        })
</script>
<script>
       /*  $('body').on('click','#meiqiakefu',function(){
            $('#MEIQIA-BTN-ICON').click();
        }); */
        function showMeiqia() {
            $('#MEIQIA-BTN-ICON').click();
            location.href= location.href+'#sdsd';
        }
</script>

<?php if($memberinfo['uid']!=1481) { ?>
    <style>
        #MEIQIA-BTN {
            display:none;
        }
    </style>
<?php } ?>

</body>
</html>